Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to change OpenJDK versions from 11 to 8 #42

Conversation

ryanbourdais
Copy link
Contributor

@ryanbourdais ryanbourdais commented Jun 17, 2022

Added a new job to allow switch OpenJDK versions per this issue

Description
Wrote a command with 3 steps, the first to check the current OpenJDK version, the second changes the default OpenJDK version of the current image to OpenJDK v8, and the third step confirms the change by running java -version once more
Also, added a parameter that will allow you to change OpenJDK versions, default: '1.8.0'. To check available OpenJDK versions, run update-java-alternatives --list

@ryanbourdais ryanbourdais requested a review from a team as a code owner June 17, 2022 19:06
@ryanbourdais ryanbourdais changed the title Change jdk versions from 11 to 8 Add command to change OpenJDK versions from 11 to 8 Jun 17, 2022
Copy link
Contributor

@JalexChen JalexChen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I would probably make the comments in a separate commit to keep the PR cleaner
  2. That command is not available on newer versions of java (e.g the default 11 - gonna need to find something different. Additionally, you may need to install the actual version of Java before you can set it. In terms of actually checking the version, maybe some logic to stop the command from executing if the version matches what they're trying to change it to would be nice
  3. I'm not sure about the JAVA_HOME significance, but CircleCI's environment can be different than most; the PATH could be different
  4. I would also put a test into the actual configuration to see if this works

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:7588031559f4e01ba198c69979bd5d6b64a609f2

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:dd3024e5ed6c1d4f7c30bb6aff3aefed9de3b7e8

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:d1a343d7eecb7d1d14e2e411285703fc595ad143

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:b8a007f73bdaf3cfd1fc14c519e76e097c2db469

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:c3e90ec8595813a1117fad368c50123a3fe6006c

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:6e09439e23f236c0a872b039af53a11a1d18cb86

@ryanbourdais
Copy link
Contributor Author

Added check to ensure that the requested java version is not the currently set version, as well as added code to set the JAVA_HOME and PATH variables following the installation of a new java version

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:2b5552e58c4c4de6d614a9ed9e883263e672004c

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:2114a13d668e90a1341e54d9d3a8c30630376196

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:caddd94ebd2aecee939e6fc7d51117181642edf1

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:219709b83a9078c8ff05e2b5f854e0ea42edfba4

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:b9d95c938358a86657060745c521fdf8d6e0a4b9

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:7c6e026ed9f0bcf33c3652e689ab618e9f8946fd

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:da34a835404de6f7871141ccac225bf72a9450fe

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:8c47c72d0506c3ec4c95a4dd5a0f1ad8f5710bd5

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:ea53781abcf38d87b0b895ca52d2ab2d9bfdda37

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:35d88ad6f7cd0344718eb3088e9fb1bf356cc4f7

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:08ecdfd446b1986a2e415fdc9a61b9630dcc1247

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:227bc2a6bb78161a69f4e2416ef9121bdafb8cf6

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:03ed086c46de15bb693b2c1a29566f3b86597fb5

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:9bc6df0eac6229f1121dd3b978694c98eb7896e8

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:cbf42082c5663b155646352dd4db9629f469d950

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:b3e8896c1def890268274e2889bffdd1dfcfd8fb

@ryanbourdais
Copy link
Contributor Author

Here is a link to a green build of the current PR:
https://app.circleci.com/pipelines/github/ryanbourdais/android-orb/33/workflows/453ec5c6-2976-4b8a-941a-934ab223b2f2

The current PR has coverage for switch to OpenJDK versions 8 and 11, as well as for installing other versions of OpenJDK such as version 13

JalexChen
JalexChen previously approved these changes Jun 21, 2022
@JalexChen
Copy link
Contributor

i think it looks fine, but i would want to get a second review as well

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:6a1baf326646539568cb35ebb7f6e5269176191d

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:743a7fceca2a9e261e8a5d04849da642838036b1

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:bfd3fa181b3fe1e996d6a5b5831f3377c9c461b9

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:13c4a903038b129ea99d8ef9c838270f21fadae8

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:aa6ebfc48cb76a6a4abf8f6d639068c722ba7575

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:abe7ea6202eab654f78f3f7412467fb1a4b73317

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:1f34c1d31937cf1434268b3e2b13fb9d07577685

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:915a662c05b8b749b3fa58cbc73bb5bb5f73288d

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:bab1abf6ebbeadd174430e2f3ac70a5f6367cd30

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:6a8957dcdda9d30fe16ef27b5bf55452e9015acd

Copy link
Contributor

@FelicianoTech FelicianoTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good PR. Needs a few changes but otherwise looks good.

I originally envisioned this feature as a bash script in the image itself as opposed to a command in the orb. This method works too. The added advantage as well is now this command will show up on the orb docs page making it more discoverable. Awesome.

I also LOVE how a test for this new feature was included in this PR.

Version to use in the change-java-version job
executor:
name: android/android-docker
tag: "2021.10.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android VM images are released every 1-2 months. We probably want to use a bit of a newer image here.

.circleci/test-deploy.yml Show resolved Hide resolved
if [ "$JAVA_VER" -ne <<parameters.java-version>> ] || [ "$JAVAC_VER" -ne <<parameters.java-version>> ]; then
exit 1
else
exit 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 41 and 42 are unnecessary here. Since this shell ends right when the "command" key ends, it will automatically return an exit code of 0 anyway.

exit 1
else
exit 0
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note as above.

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:46fc9291528b4446d64ae10ea3ab2a7d975b166a

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:9ee9d15a2e1b38f2579b347d1b1eb0a2e4bd7ad1

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:80040d1c2f2e96849bdb315351d39c08ef6c4436

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:86c23db5d8db2a33c6354e9e7733c268f8f18ce8

EricRibeiro
EricRibeiro previously approved these changes Jun 21, 2022
Copy link
Contributor

@EricRibeiro EricRibeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

FelicianoTech
FelicianoTech previously approved these changes Jun 22, 2022
name: "Test OpenJDK version change"
executor:
name: android/android-docker
tag: "2021.10.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would still be nice to have updated but I won't hold back this PR for it.

@ryanbourdais ryanbourdais force-pushed the change-jdk-versions-from-11-to-8 branch from 86c23db to 86f3c38 Compare June 22, 2022 17:32
@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:86f3c382b8a94e741ac01e3f92a46eb9c1f5440e

@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:737ab191652cc89837a23575f822d5283c59a181

@ryanbourdais ryanbourdais force-pushed the change-jdk-versions-from-11-to-8 branch from 737ab19 to 121f665 Compare June 22, 2022 17:42
@ryanbourdais
Copy link
Contributor Author

Your development orb has been published. It will expire in 30 days.
You can preview what this will look like on the CircleCI Orb Registry at the following link:
https://circleci.com/developer/orbs/orb/circleci/android?version=dev:121f665a931e1653453f8b09dae65b0dd3ebf609

Copy link
Contributor

@EricRibeiro EricRibeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ryanbourdais ryanbourdais merged commit 50be37b into CircleCI-Public:main Jun 22, 2022
@ryanbourdais ryanbourdais deleted the change-jdk-versions-from-11-to-8 branch June 22, 2022 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants